<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<meta charset="utf-8" content="">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>填写地址</title>
<link rel="stylesheet"
	href="http://cache.amap.com/lbs/static/main1119.css" />
<script type="text/javascript"
	src="http://webapi.amap.com/maps?v=1.3&amp;key=f9d326eec206fa5f8ae57ccb028fc9bb&amp;plugin=AMap.Autocomplete,AMap.PlaceSearch"></script>


<link href="${ctx }/styles/BJUI/new/css/bootstrap.min.css"
	rel="stylesheet">
<!-- Font-awesome 图标 CSS库 -->
<link href="${ctx }/styles/BJUI/new/css/font-awesome.min.css"
	rel="stylesheet">
<!-- JQuery UI CSS库 -->
<link href="${ctx }/styles/BJUI/new/css/jquery-ui.min.css"
	rel="stylesheet">
<!-- JQuery -->
<script src="${ctx }/styles/BJUI/new/js/jquery-1.10.2.min.js"
	type="text/javascript"></script>
<script src="${ctx }/styles/BJUI/new/js/jquery.unobtrusive-ajax.min.js"
	type="text/javascript"></script>
<!-- JQuery UI -->
<script src="${ctx }/styles/BJUI/new/js/jquery-ui.min.js"
	type="text/javascript"></script>
<!-- 脉动提示插件 -->
<script src="${ctx }/styles/BJUI/new/js/jquery.pulsate.min.js"
	type="text/javascript"></script>
<!-- Bootstrap 核心 JS库 -->
<script src="${ctx }/styles/BJUI/new/js/bootstrap.min.js"
	type="text/javascript"></script>
<!-- 浏览器判断 -->
<script src="${ctx }/styles/BJUI/new/js/Browser.js"
	type="text/javascript"></script>
<!-- 母版页 样式 -->
<link href="${ctx }/styles/BJUI/new/css/carousel.css" rel="stylesheet">
<link href="${ctx }/styles/BJUI/new/css/style.css" rel="stylesheet">
<link href="${ctx }/styles/BJUI/new/css/leon.css" rel="stylesheet">
<link href="${ctx }/styles/BJUI/new/css/index.css" rel="stylesheet">
</head>
<body style="background-color: #dedede;">
	<form id="form" class="form-inline" action="">

		<div class="clearfix">
			<div class="carousel-inner" id="order_container">

				<div class="row" style="padding: 10px 10px 0 10px;">
					<div class="col-sm-8 box-size-40" style="background-color: #dedede">
						<input oninput="keywords(this)" style="border: 1px solid #FF8800;"
							class="input-max display-left placeholder-left"  id ="in"
							placeholder="${str}">
					</div>
					<div id="content" class='carousel-inner' id='order_container'
						style='margin-top: 10px'></div>
				</div>
			</div>


		</div>
		<!--		<input type="hidden" name="originLongitude" id="originLongitude"
			value="${list.originLongitude}" /> <input type="hidden"
			name="originLatitude" id="originLatitude"
			value="${list.originLatitude}" /> <input type="hidden"
			name="destinationLatitude" id="destinationLatitude"
			value="${list.destinationLatitude}" /> <input type="hidden"
			name="destinationLongitude" id="destinationLongitude"
			value="${list.destinationLongitude}" /> <input type="hidden"
			name="vehicleType" id="vehicleType" value="${list.vehicleType}" /> <input
			type="hidden" name="distance" id="distance"
			value="${list.vehicleType}" /> <input type="hidden" name="payType"
			id="payType" value="2" /> <input type="hidden" name="money"
			id="money" value="${list.money}" /> <input type="hidden"
			name="launchAccountId" id="launchAccountId"
			value="${list.launchAccountId}" /> <input id="originAddress"
			name="originAddress" type="hidden" value="${list.originAddress}">
		<input id="destinationAddress" name="destinationAddress" type="hidden"
			value="${list.destinationAddress}"> <input id="originName"
			name="originName" type="hidden" value="${list.originName}"> <input
			id="originPhone" name="originPhone" type="hidden"
			value="${list.originPhone}"> <input id="destinationName"
			name="destinationName" type="hidden"
			value="${list.destinationAddress}"> <input
			id="destinationPhone" name="destinationPhone" type="hidden"
			value="${list.destinationAddress}"><input id="goodsName"
			name="goodsName" type="hidden" value="${list.goodsName}"><input
			id="remarks" name="remarks" type="hidden" value="${list.remarks}">
		<input id="addPrice" name="addPrice" type="hidden"
			value="${list.addPrice}">-->
	</form>
	<script type="text/javascript">
		$(function() {
		var oInput = document.getElementById("in");
oInput.focus();
		});
		var autoOptions = {
			city : "广西南宁市"
		};
		var auto = new AMap.Autocomplete(autoOptions);

		function keywords(e) {
			auto
					.search(
							e.value,
							function(status, result) {
								if (status == "complete") {
									var tips = result['tips'];
									var str = "";
									for (i = 0; i < tips.length; i++) {
										var address = tips[i]['district']
												+ tips[i]['address'];
												address="("+ tips[i]['name']+")"+address;
										var item = tips[i];
										str = str
												+ "<div   onclick='select(\""
												+ address
												+ "\","
												+ tips[i]['location']['lat']
												+ ","
												+ tips[i]['location']['lng']
												+ ")' style='background-color: #ffffff;border: 1px solid #ffffff;border-radius: 3px;margin: 10px'>"
												+ "   <div class='label-text-sm'>"
												+ tips[i]['name']
												+ "</div><div class='label-text-smm'>"
												+ tips[i]['district']
												+ tips[i]['address']
												+ " </div>  </div>";
									}

									$("#content").html(str);
								//  alert(JSON.stringify(result));
								}
							});

		}
		//AMap.event.addListener(auto, "select", select);//注册监听，当选中某条记录时会触发
		function select(address, lat, lng) {

			//var address = e['poi']['district'];
			//		address = address + e['poi']['address'];
			//	var lat = e['poi']['location']['lat'];
			//	var lng = e['poi']['location']['lng'];
			//	$("#destinationLatitude").val(lat);
			//	$("#destinationLongitude").val(lng);
			//	$("#destinationAddress").val(address);		
			var PositionType = "${PositionType}";
//			alert("PositionType="+PositionType+"<br> lat="+lat+"<br>lng="+lng+"<br>address"+address);

			address = encodeURI(address);

			if (PositionType == 1) {

				window.location.href = "${ctx }/weixinView/positionTwo?destinationLatitude="
						+ lat
						+ "&destinationLongitude="
						+ lng
						+ "&destinationAddress="
						+ encodeURI(address)
						+ "&positionType=" + PositionType;
			}
			if (PositionType == 2) {
				window.location.href = "${ctx }/weixinView/positionTwo?originLatitude="
						+ lat
						+ "&originLongitude="
						+ lng
						+ "&originAddress="
						+ encodeURI(address) + "&positionType=" + PositionType;
			}

		}
	</script>
</body>
</html>
